
%b)
n = 100;
probBitSwap = 0.05;

figure();
hold on;
title('PMF of Bit Swaps (true calculation)');
axis([0 n 0 0.2]);

for i = 0:n
    pmfBitSwapTrue = nchk(n,i)*(probBitSwap^i)*((1-probBitSwap)^(n-i));
    stem(i,pmfBitSwapTrue);
end;

%now poisson:

figure();
hold on;
title('PMF swaps occured (approx)');
axis([0 n 0 0.2]);

lambda = n*probBitSwap;

for i = 0:n
    pmfBitSwapApprox = (lambda^(i)/factorial(i))*exp(-lambda);
    stem(i,pmfBitSwapApprox);
end;


